/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlepgto.beans;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Thiago
 */
@Entity
@Table(name = "parcela", catalog = "controlepgto", schema = "")
@NamedQueries({
    @NamedQuery(name = "Parcela.findAll", query = "SELECT p FROM Parcela p"),
    @NamedQuery(name = "Parcela.findByIdParcela", query = "SELECT p FROM Parcela p WHERE p.idParcela = :idParcela"),
    @NamedQuery(name = "Parcela.findByNumeroParcela", query = "SELECT p FROM Parcela p WHERE p.numeroParcela = :numeroParcela"),
    @NamedQuery(name = "Parcela.findByDataVencParcela", query = "SELECT p FROM Parcela p WHERE p.dataVencParcela = :dataVencParcela"),
    @NamedQuery(name = "Parcela.findByValorParcela", query = "SELECT p FROM Parcela p WHERE p.valorParcela = :valorParcela"),
    @NamedQuery(name = "Parcela.findByStatusParcela", query = "SELECT p FROM Parcela p WHERE p.statusParcela = :statusParcela"),
    @NamedQuery(name = "Parcela.findByDataPgtoParcela", query = "SELECT p FROM Parcela p WHERE p.dataPgtoParcela = :dataPgtoParcela"),
    @NamedQuery(name = "Parcela.findByAcresDescParcela", query = "SELECT p FROM Parcela p WHERE p.acresDescParcela = :acresDescParcela"),
    @NamedQuery(name = "Parcela.findByObsParcela", query = "SELECT p FROM Parcela p WHERE p.obsParcela = :obsParcela")})
public class Parcela implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_parcela")
    private Integer idParcela;
    @Basic(optional = false)
    @Column(name = "numero_parcela")
    private int numeroParcela;
    @Basic(optional = false)
    @Column(name = "data_venc_parcela")
    @Temporal(TemporalType.DATE)
    private Date dataVencParcela;
    @Basic(optional = false)
    @Column(name = "valor_parcela")
    private double valorParcela;
    @Column(name = "status_parcela")
    private String statusParcela;
    @Column(name = "data_pgto_parcela")
    @Temporal(TemporalType.DATE)
    private Date dataPgtoParcela; 
    @Column(name = "acres_desc_parcela")
    private Double acresDescParcela;
    @Column(name = "obs_parcela")
    private String obsParcela;
    
    @JoinColumn(name = "id_compra", referencedColumnName = "id_compra")
    @ManyToOne(optional = false)
    private Compra idCompra;

    public Parcela() {
    }

    public Parcela(Integer idParcela) {
        this.idParcela = idParcela;
    }

    public Parcela(Integer idParcela, int numeroParcela, Date dataVencParcela, double valorParcela) {
        this.idParcela = idParcela;
        this.numeroParcela = numeroParcela;
        this.dataVencParcela = dataVencParcela;
        this.valorParcela = valorParcela;
    }

    public Integer getIdParcela() {
        return idParcela;
    }

    public void setIdParcela(Integer idParcela) {
        Integer oldIdParcela = this.idParcela;
        this.idParcela = idParcela;
        changeSupport.firePropertyChange("idParcela", oldIdParcela, idParcela);
    }

    public int getNumeroParcela() {
        return numeroParcela;
    }

    public void setNumeroParcela(int numeroParcela) {
        int oldNumeroParcela = this.numeroParcela;
        this.numeroParcela = numeroParcela;
        changeSupport.firePropertyChange("numeroParcela", oldNumeroParcela, numeroParcela);
    }

    public Date getDataVencParcela() {
        return dataVencParcela;
    }

    public void setDataVencParcela(Date dataVencParcela) {
        Date oldDataVencParcela = this.dataVencParcela;
        this.dataVencParcela = dataVencParcela;
        changeSupport.firePropertyChange("dataVencParcela", oldDataVencParcela, dataVencParcela);
    }

    public double getValorParcela() {
        return valorParcela;
    }

    public void setValorParcela(double valorParcela) {
        double oldValorParcela = this.valorParcela;
        this.valorParcela = valorParcela;
        changeSupport.firePropertyChange("valorParcela", oldValorParcela, valorParcela);
    }

    public String getStatusParcela() {
        return statusParcela;
    }

    public void setStatusParcela(String statusParcela) {
        String oldStatusParcela = this.statusParcela;
        this.statusParcela = statusParcela;
        changeSupport.firePropertyChange("statusParcela", oldStatusParcela, statusParcela);
    }

    public Date getDataPgtoParcela() {
        return dataPgtoParcela;
    }

    public void setDataPgtoParcela(Date dataPgtoParcela) {
        Date oldDataPgtoParcela = this.dataPgtoParcela;
        this.dataPgtoParcela = dataPgtoParcela;
        changeSupport.firePropertyChange("dataPgtoParcela", oldDataPgtoParcela, dataPgtoParcela);
    }

    public Double getAcresDescParcela() {
        return acresDescParcela;
    }

    public void setAcresDescParcela(Double acresDescParcela) {
        Double oldAcresDescParcela = this.acresDescParcela;
        this.acresDescParcela = acresDescParcela;
        changeSupport.firePropertyChange("acresDescParcela", oldAcresDescParcela, acresDescParcela);
    }

    public String getObsParcela() {
        return obsParcela;
    }

    public void setObsParcela(String obsParcela) {
        String oldObsParcela = this.obsParcela;
        this.obsParcela = obsParcela;
        changeSupport.firePropertyChange("obsParcela", oldObsParcela, obsParcela);
    }

    public Compra getIdCompra() {
        return idCompra;
    }

    public void setIdCompra(Compra idCompra) {
        Compra oldIdCompra = this.idCompra;
        this.idCompra = idCompra;
        changeSupport.firePropertyChange("idCompra", oldIdCompra, idCompra);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idParcela != null ? idParcela.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Parcela)) {
            return false;
        }
        Parcela other = (Parcela) object;
        if ((this.idParcela == null && other.idParcela != null) || (this.idParcela != null && !this.idParcela.equals(other.idParcela))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "controlepgto.view.Parcela[ idParcela=" + idParcela + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
